package com.dm.entity;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;

/**
 * @author hqw521@qq.com
 * @date 2018/11/12 20:35
 */
@Entity
@Table(name = "dm_folder", schema = "dm", catalog = "")
public class Folder {
    private int folderId;
    private String folderName;
    private String folderKeyWord;
    private Integer parentFolder;
    private Integer userId;
    private Timestamp createTime;
    private Timestamp updateTime;
    private List<File> dmFilesByFolderId;
    private Folder dmFolderByParentFolder;
    private List<Folder> dmFoldersByFolderId;
    private User dmUserByUserId;
    private List<Record> dmRecordsByFolderId;

    @Id
    @Column(name = "folder_id", nullable = false)
    public int getFolderId() {
        return folderId;
    }

    public void setFolderId(int folderId) {
        this.folderId = folderId;
    }

    @Basic
    @Column(name = "folder_name", nullable = false, length = 20)
    public String getFolderName() {
        return folderName;
    }

    public void setFolderName(String folderName) {
        this.folderName = folderName;
    }

    @Basic
    @Column(name = "folder_keyWord", nullable = true, length = 50)
    public String getFolderKeyWord() {
        return folderKeyWord;
    }

    public void setFolderKeyWord(String folderKeyWord) {
        this.folderKeyWord = folderKeyWord;
    }

    @Basic
    @Column(name = "parent_folder", nullable = true)
    public Integer getParentFolder() {
        return parentFolder;
    }

    public void setParentFolder(Integer parentFolder) {
        this.parentFolder = parentFolder;
    }

    @Basic
    @Column(name = "user_id", nullable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @OneToMany(mappedBy = "dmFolderByFolderId")
    public List<File> getDmFilesByFolderId() {
        return dmFilesByFolderId;
    }

    public void setDmFilesByFolderId(List<File> dmFilesByFolderId) {
        this.dmFilesByFolderId = dmFilesByFolderId;
    }

    @ManyToOne
    @JoinColumn(name = "parent_folder", referencedColumnName = "folder_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public Folder getDmFolderByParentFolder() {
        return dmFolderByParentFolder;
    }

    public void setDmFolderByParentFolder(Folder dmFolderByParentFolder) {
        this.dmFolderByParentFolder = dmFolderByParentFolder;
    }

    @OneToMany(mappedBy = "dmFolderByParentFolder")
    public List<Folder> getDmFoldersByFolderId() {
        return dmFoldersByFolderId;
    }

    public void setDmFoldersByFolderId(List<Folder> dmFoldersByFolderId) {
        this.dmFoldersByFolderId = dmFoldersByFolderId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public User getDmUserByUserId() {
        return dmUserByUserId;
    }

    public void setDmUserByUserId(User dmUserByUserId) {
        this.dmUserByUserId = dmUserByUserId;
    }

    @OneToMany(mappedBy = "dmFolderByFolderId")
    public List<Record> getDmRecordsByFolderId() {
        return dmRecordsByFolderId;
    }

    public void setDmRecordsByFolderId(List<Record> dmRecordsByFolderId) {
        this.dmRecordsByFolderId = dmRecordsByFolderId;
    }
}
